#include <iostream>
#include <chrono>
#include <vector>
#include <numeric>
#include <execution>
 
int main()
{
    std::vector<double> v(1000'000'007, 0.5);
 
    {
        double result=0.0;
        auto t1 = std::chrono::high_resolution_clock::now();
        for(int i=0;i<10;++i)
         result += std::accumulate(v.begin(), v.end(), 0.0);
        auto t2 = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double, std::milli> ms = t2 - t1;
        std::cout << std::fixed << "std::accumulate result " << result
                  << " took " << ms.count() << " ms\n";
    }
 
    {
        double result =0.0;
        auto t1 = std::chrono::high_resolution_clock::now();
        for(int i=0;i<10;++i)
         result += std::reduce(std::execution::unseq, v.begin(), v.end());
        auto t2 = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double, std::milli> ms = t2 - t1;
        std::cout << "std::reduce result "
                  << result << " took " << ms.count() << " ms\n";
    }
}
// par没啥效果，还慢了？par
// unseq:
//  std::accumulate result 4658.492180 took 4518.276411 ms
// std::reduce result 4560.513873 took 4516.467516 ms
// unseq快了一点点